package org.example.postgraduateproject.Test;

import org.example.postgraduateproject.Dao.UserDao;
import org.example.postgraduateproject.Dao.imp.UserDaoImp;
import org.example.postgraduateproject.entity.User;

import java.util.List;

/**
 * @author bin
 * @date 2025-05-11
 */
public class UserTest {
    public static void main(String[] args) {
        UserDao userDao = new UserDaoImp();
//        List<User> users = userDao.selectAllUser();
//        System.out.println(users);
//        User user = userDao.loginSelectUserName("john_doe");


        User user = new User();
        user.setUserName("test_user");
        user.setPassWord("test_password");
        user.setEmail("test@example.com");
        user.setPhone("1234567890");

        // 调用注册方法
        int rowsAffected = userDao.regUser(user);

        // 输出结果
        if (rowsAffected > 0) {
            System.out.println("用户注册成功！影响行数：" + rowsAffected);
        } else {
            System.out.println("用户注册失败！");
        }

        // 验证注册结果（可选）
        User registeredUser = userDao.loginSelectUserName("test_user");
        if (registeredUser != null) {
            System.out.println("验证成功：" + registeredUser.getUserName());
        } else {
            System.out.println("验证失败：用户未找到！");
        }
    }
}
